package com.sys.SysFeedingRecords.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysFeedingRecords.domain.SysFeedingRecords;
import com.sys.SysFeedingRecords.service.ISysFeedingRecordsService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 投喂记录Controller
 * 
 * @author sys
 * @date 2025-09-04
 */
@RestController
@RequestMapping("/SysFeedingRecords/SysFeedingRecords")
public class
SysFeedingRecordsController extends BaseController
{
    @Autowired
    private ISysFeedingRecordsService sysFeedingRecordsService;

    /**
     * 查询投喂记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysFeedingRecords sysFeedingRecords)
    {
        startPage();
        List<SysFeedingRecords> list = sysFeedingRecordsService.selectSysFeedingRecordsList(sysFeedingRecords);
        return getDataTable(list);
    }

    /**
     * 导出投喂记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:export')")
    @Log(title = "投喂记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysFeedingRecords sysFeedingRecords)
    {
        List<SysFeedingRecords> list = sysFeedingRecordsService.selectSysFeedingRecordsList(sysFeedingRecords);
        ExcelUtil<SysFeedingRecords> util = new ExcelUtil<SysFeedingRecords>(SysFeedingRecords.class);
        util.exportExcel(response, list, "投喂记录数据");
    }

    /**
     * 获取投喂记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysFeedingRecordsService.selectSysFeedingRecordsById(id));
    }

    /**
     * 新增投喂记录
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:add')")
    @Log(title = "投喂记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysFeedingRecords sysFeedingRecords)
    {

        AjaxResult ajaxResult = sysFeedingRecordsService.insertSysFeedingRecords(sysFeedingRecords);
        System.out.println(ajaxResult);
        return toAjax(ajaxResult);
    }

    /**
     * 修改投喂记录
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:edit')")
    @Log(title = "投喂记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysFeedingRecords sysFeedingRecords)
    {
        return toAjax(sysFeedingRecordsService.updateSysFeedingRecords(sysFeedingRecords));
    }

    /**
     * 删除投喂记录
     */
    @PreAuthorize("@ss.hasPermi('SysFeedingRecords:SysFeedingRecords:remove')")
    @Log(title = "投喂记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysFeedingRecordsService.deleteSysFeedingRecordsByIds(ids));
    }
}
